<me:UIWDECK x:Class="WPFExcelReport.TR2EKWD02"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:ucd="clr-namespace:ReflectionStudio.Controls;assembly=ReflectionStudio.Controls"     
                    xmlns:me="clr-namespace:WPFExcelReport" 
                    xmlns:T="clr-namespace:WPFExcelReport;assembly=IntexBL" 
                    xmlns:SD="clr-namespace:WPFExcelReport;assembly=TSDDAT"  
                    xmlns:WH="clr-namespace:WPFExcelReport;assembly=TLAGPL"  
                    xmlns:PR="clr-namespace:WPFExcelReport;assembly=TICC_PRULES"  
                    xmlns:LS="clr-namespace:WPFExcelReport;assembly=TLIEFDAT"  
                    xmlns:ABK="clr-namespace:WPFExcelReport;assembly=TABKOPF"  
                    xmlns:MU="clr-namespace:WPFExcelReport;assembly=TABAUFM"  
                     xmlns:ex="clr-namespace:WPFExcelReport.Controls;assembly=ExControls" 
                    xmlns:Localization="clr-namespace:Localization;assembly=Localization"
                    x:Name="TV"
                    Loaded="Window_Loaded"
     >
    <me:UIWDECK.Resources>
        <CollectionViewSource  x:Key="vwMaster"/>
        <CollectionViewSource  x:Key="vwDetail"/>
        <ucd:Divideby10  x:Key="d10"/>
        <ucd:BoolToVisibilityConverter  x:Key="bv"/>
        <ucd:NOTBoolToVisibilityConverter x:Key="nbv"/>
        <ucd:NOTConverter  x:Key="not"/>
        <ucd:Divideby100  x:Key="d100"/>
        <ucd:Divideby1000  x:Key="d1000"/>
        <ucd:GB2312Convert8859P1  x:Key="gb2312"/>
        <ucd:TextTrimmingConverter x:Key="trim"/>
        <ucd:PNumConverter x:Key="pnum"/>
        <ucd:LSCONV x:Key="ls"/>
    </me:UIWDECK.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="1*"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="1*"></RowDefinition>
        </Grid.RowDefinitions>

        <StackPanel Grid.Row="0"     Visibility="{Binding IsAuto,ElementName=TV,Converter={StaticResource nbv}}">
            <WrapPanel >
                <Grid Margin="10,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <TextBlock   Grid.Column="0" Text="{Binding Source={Localization:Translate Word=品种:}}"></TextBlock>
                    <ex:AutoTrimTextBox MaxLength="24" Grid.Column="1" CharacterCasing="Upper" Text="{Binding ART,ElementName=TV}" Width="180" />
                </Grid>
                <Grid Margin="10,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <TextBlock   Grid.Column="0" Text="{Binding Source={Localization:Translate Word=色号:}}"></TextBlock>
                    <ex:AutoTrimTextBox MaxLength="10" Grid.Column="1" CharacterCasing="Upper" Text="{Binding FARBE,ElementName=TV}" Width="80" />
                </Grid>
                <WrapPanel>
                    <TextBlock   Grid.Column="0" Text="{Binding Source={Localization:Translate Word=类型:}}"></TextBlock>
                    <ex:TXT72 MaxLength="1" Grid.Column="0" Text="{Binding AUFART,ElementName=TV}" Width="30" />
                    <TextBlock   Grid.Column="0" Text="{Binding Source={Localization:Translate Word=单号:}}"></TextBlock>
                    <ex:TXT72 MaxLength="2" Grid.Column="1" Text="{Binding KRS,ElementName=TV}" Width="30" />
                    <ex:TXT72 MaxLength="6" Grid.Column="2" Text="{Binding LFD,ElementName=TV}" Width="80" />
                    <ex:TXT72 MaxLength="3" Grid.Column="3"  Text="{Binding POS,ElementName=TV}" Width="40" />
                </WrapPanel>
                <Button  Click="QueryCommand" Height="20" Margin="5,0,0,0" Width="24" >
                    <Button.Background>
                        <ImageBrush  ImageSource="/ImagePackage;component/Images/Search.png" />
                    </Button.Background>
                </Button>
                <WrapPanel>
                    <Button Margin="10,0,0,0" Click="NewCommand" Height="20"  Width="Auto"
                            Content="{Binding Source={Localization:Translate Word=准备采购}}" />
                    <Button Margin="10,0,0,0" Click="ByLSCommand" Height="20"  Width="Auto"
                            Content="{Binding Source={Localization:Translate Word=相同供应商}}" />
                </WrapPanel>
            </WrapPanel> 
            <WrapPanel>
                <Grid Margin="10,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <TextBlock   Grid.Column="0" Text="{Binding Source={Localization:Translate Word=计划数量:}}"></TextBlock>
                    <ex:AutoTrimTextBox MaxLength="10" Grid.Column="1" CharacterCasing="Upper" Text="{Binding QTY,Source={StaticResource vwMaster}}" Width="80" />
                </Grid>
                <Grid Margin="10,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <TextBlock   Grid.Column="0" Text="{Binding Source={Localization:Translate Word=单价:}}"></TextBlock>
                    <ex:TXT72 MaxLength="10" Grid.Column="1" CharacterCasing="Upper" Text="{Binding PREK,Source={StaticResource vwMaster}}" Width="80" />
                </Grid>
                <Grid Margin="10,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <TextBlock   Grid.Column="0" Text="{Binding Source={Localization:Translate Word=币种:}}"></TextBlock>
                    <ex:TXT72 MaxLength="10" Grid.Column="1" CharacterCasing="Upper" Text="{Binding WAEHRSL,Source={StaticResource vwMaster}}" Width="60" />
                </Grid>
                <Grid Margin="10,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <TextBlock   Grid.Column="0" Text="{Binding Source={Localization:Translate Word=UM:}}"></TextBlock>
                    <ex:TXT72 MaxLength="10" Grid.Column="1" CharacterCasing="Upper" Text="{Binding UM,Source={StaticResource vwMaster}}" Width="40" />
                </Grid>
                <Button   Click="EditCommand" Height="20" Margin="5,0,0,0" Width="24" >
                    <Button.Background>
                        <ImageBrush  ImageSource="/ImagePackage;component/Images/Edit.png" />
                    </Button.Background>
                </Button>
                <TextBlock Text="{Binding Source={Localization:Translate Word=更改供应商}}"/>
                <TextBlock  Margin="5,0,0,0"   Text= "供应商:"/>
                <LS:TSLS02 KEY="{Binding LIEFNR,ElementName=TV}" Visibility="{Binding IsEdit,ElementName=TV,Converter={StaticResource bv}}"
                           IsEdit="True"  />
                <TextBlock Margin="5,0,0,0"    Text="{Binding LSLIEFNA,ElementName=TV, Converter={StaticResource gb2312}}" 
                                         Width="Auto" />
                <CheckBox  IsChecked="{Binding IsShowRight,ElementName=TV}"/>
                <Grid Margin="10,0,0,0" Visibility="{Binding IsEdit,ElementName=TV,Converter={StaticResource bv}}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button   Click="SaveCommand" Height="20" Margin="5,0,0,0" Width="24" >
                        <Button.Background>
                            <ImageBrush  ImageSource="/ImagePackage;component/Images/Save.png" />
                        </Button.Background>
                    </Button>
                </Grid>
            </WrapPanel>

        </StackPanel>
        <DataGrid   Grid.Row="1"  
                   VerticalAlignment="Top"  
                   AutoGenerateColumns="False"
                   EnableRowVirtualization="False"
                   IsReadOnly="True"
                   VerticalScrollBarVisibility="Auto"
                   HorizontalScrollBarVisibility="Auto"
                   HeadersVisibility="Column"   
                   ItemsSource="{Binding Source={StaticResource ResourceKey=vwMaster}}" 
                   IsSynchronizedWithCurrentItem="True" 
                   x:Name="dlgMaster"  
                   RowDetailsVisibilityMode="Visible"  
                    >
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding Path=WDAUFKRS}" Header=""  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=WDAUFLFD,Converter={StaticResource ResourceKey=pnum}}" Header="{Binding Source={Localization:Translate Word=需求单}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=WDAUFPOS,Converter={StaticResource ResourceKey=pnum}}" Header=""  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=WDART}" Header="{Binding Source={Localization:Translate Word=品种}}"  Width="60" />
                <DataGridTextColumn Binding="{Binding Path=QTY}" Header="{Binding Source={Localization:Translate Word=计划量}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=PREK}" Header="{Binding Source={Localization:Translate Word=单价}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=WAEHRSL}" Header="{Binding Source={Localization:Translate Word=￥}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=UM}" Header="{Binding Source={Localization:Translate Word=UM}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=LSLIEFNR,Converter={StaticResource ResourceKey=pnum}}"   Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=LSLIEFNR, Converter={StaticResource ResourceKey=ls},ConverterParameter=LS02}" Header="{Binding Source={Localization:Translate Word=供应商}}" Width="Auto" MinWidth="30"  />
                <DataGridTextColumn Binding="{Binding Path=WDBEDARF,Converter={StaticResource ResourceKey=d100}}" Header="{Binding Source={Localization:Translate Word=需求}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=WDZUGET,Converter={StaticResource ResourceKey=d100}}" Header="{Binding Source={Localization:Translate Word=留位}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=WDRESERV,Converter={StaticResource ResourceKey=d100}}" Header="{Binding Source={Localization:Translate Word=预留}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=WDDAT,Converter={StaticResource ResourceKey=gb2312}}" Header="{Binding Source={Localization:Translate Word=日期}}"  Width="Auto" />
            </DataGrid.Columns>
        </DataGrid  >
        <WrapPanel Grid.Row="2" >
            <Button   Click="DeleteCommand" Height="20" Margin="5,0,0,0" Width="24" >
                <Button.Background>
                    <ImageBrush  ImageSource="/ImagePackage;component/Images/Remove.png" />
                </Button.Background>
            </Button>
            <Button   Click="Conver2EKK" Height="20" Margin="5,0,0,0" Width="24" >
                <Button.Background>
                    <ImageBrush  ImageSource="/ImagePackage;component/Images/Convert.png" />
                </Button.Background>
            </Button>
        </WrapPanel>
        <DataGrid   Grid.Row="3"    
                   VerticalAlignment="Top"  
                   AutoGenerateColumns="False"
                   EnableRowVirtualization="False"
                   IsReadOnly="True"
                   VerticalScrollBarVisibility="Auto"
                   HorizontalScrollBarVisibility="Auto"
                   HeadersVisibility="Column"   
                   ItemsSource="{Binding Source={StaticResource ResourceKey=vwDetail}}" 
                   IsSynchronizedWithCurrentItem="True"  
                   RowDetailsVisibilityMode="Visible"  
                    >
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding Path=WDAUFKRS}" Header=""  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=WDAUFLFD,Converter={StaticResource ResourceKey=pnum}}" Header="{Binding Source={Localization:Translate Word=需求单}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=WDAUFPOS,Converter={StaticResource ResourceKey=pnum}}" Header=""  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=WDART,Converter={StaticResource ResourceKey=trim}}" Header="{Binding Source={Localization:Translate Word=品种}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=WDFARBE,Converter={StaticResource ResourceKey=gb2312}}" Header="{Binding Source={Localization:Translate Word=色号}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=QTY}" Header="{Binding Source={Localization:Translate Word=待采购量}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=PREK}" Header="{Binding Source={Localization:Translate Word=单价}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=WAEHRSL}" Header="{Binding Source={Localization:Translate Word=￥}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=UM}" Header="{Binding Source={Localization:Translate Word=UM}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=LSLIEFNA, Converter={StaticResource ResourceKey=gb2312}}" Header="{Binding Source={Localization:Translate Word=供应商}}" Width="Auto" MinWidth="30"  />
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</me:UIWDECK>
